home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 84 / 084.d81 / source codes / TOOLBOX SOURCE < prev   
Text File  |  2022-08-26  |  13KB  |  1,146 lines

  1. .org $c000
  2. ;mem
  3. .obj "@0:sys toolbox.o"
  4. lda 648
  5. cmp current'screen
  6. beq +
  7. jsr set'screen'table
  8.  
  9. + jsr line'links
  10.  
  11. ldx #1
  12. stx numbers'to'get
  13. jsr get'number  ;get function number
  14.  
  15. lda number
  16.  
  17. cmp #11
  18. bcc +
  19. jmp other'table
  20.  
  21. + cmp #0
  22. beq help
  23. cmp #1
  24. beq mline
  25. cmp #2
  26. beq message
  27. cmp #3
  28. beq message'custom
  29. cmp #4
  30. beq screen'stash'enter
  31. cmp #5
  32. beq screen'restore'enter
  33. cmp #6
  34. beq fill'enter
  35. cmp #7
  36. beq box'enter
  37. cmp #8
  38. beq clear'line
  39. cmp #9
  40. beq character'swap
  41. cmp #10
  42. beq color'swap
  43. rts
  44.  
  45. help jsr helpsc
  46. rts
  47.  
  48. mline jsr move'line2
  49. rts
  50.  
  51. message'custom ldx #6
  52. stx numbers'to'get
  53. jsr get'number
  54. jsr set'message
  55. jsr message
  56. rts
  57.  
  58. message jsr get'string
  59. jsr message'routine
  60. rts
  61.  
  62. screen'stash'enter ldx #1
  63. stx numbers'to'get
  64. jsr get'number
  65. jsr screen'stash
  66. rts
  67.  
  68. screen'restore'enter ldx #1
  69. stx numbers'to'get
  70. jsr get'number
  71. jsr screen'restore
  72. rts
  73.  
  74. fill'enter ldx #5
  75. stx numbers'to'get
  76. jsr get'number
  77. fill'routine jsr wait
  78. filler jsr fill
  79. inc number
  80. ldx number
  81. cpx number+1
  82. bcc filler
  83. rts
  84.  
  85. color'swap jsr color
  86. rts
  87.  
  88. character'swap jsr char
  89. rts
  90.  
  91. box'enter ldx #6
  92. stx numbers'to'get
  93. jsr get'number
  94. box'routine jsr wait
  95. boxer jsr box
  96. inc number
  97. ldx number
  98. cpx number+1
  99. bcc boxer
  100. rts
  101.  
  102. clear'line ldx #2
  103. stx numbers'to'get
  104. jsr get'number     
  105. jsr wait
  106. ldx number
  107. - jsr 59903
  108. inc number
  109. ldx number
  110. cpx number+1
  111. bcc -
  112. rts
  113.  
  114. other'table cmp #11
  115. beq rvs'enter
  116. cmp #12
  117. beq dir'enter
  118. cmp #13
  119. beq file'read'enter
  120. rts
  121.  
  122. rvs'enter ldx #5
  123. stx numbers'to'get
  124. jsr get'number
  125. rvs'routine jsr wait
  126. rvser jsr rvs
  127. inc number
  128. ldx number
  129. cpx number+1
  130. bcc rvser
  131. rts
  132.  
  133. dir'enter ldx #1
  134. stx numbers'to'get
  135. jsr get'number
  136. lda number
  137. sta device
  138. jsr get'string
  139. lda #4
  140. sta number
  141. jsr screen'stash
  142. lda #0
  143. sta 212
  144. lda #147
  145. jsr $ffd2
  146. jsr dir
  147. - jsr $ffe4
  148. beq -
  149. lda #4
  150. sta number
  151. jsr screen'restore
  152. rts
  153.  
  154. file'read'enter ldx #2
  155. stx numbers'to'get
  156. jsr get'number
  157. lda number
  158. sta device
  159. lda number+1
  160. sta flag
  161. jsr get'string
  162. lda #4
  163. sta number
  164. jsr screen'stash
  165. lda #0
  166. sta 212
  167. lda #147
  168. jsr $ffd2
  169. jsr file'read
  170. lda #4
  171. sta number
  172. jsr screen'restore
  173. rts
  174.  
  175. ;**** get number from BASIC ****
  176.  
  177. get'number ldx #0
  178. stx current'number
  179.  
  180. - jsr $aefd
  181. jsr $ad8a
  182. jsr $b7f7
  183. lda $14  ; got it!
  184.  
  185. ldx current'number
  186. sta number,x
  187. inc current'number
  188. dec numbers'to'get
  189. beq +
  190. bne -
  191. + rts
  192.  
  193. ;***** get string from BASIC ****
  194.  
  195. get'string jsr $aefd
  196. jsr $ad9e
  197. jsr $b6a3
  198.  
  199. ldx $22
  200. ldy $23
  201. stx 251
  202. sty 252
  203. cmp #41
  204. bcc +
  205. lda #40
  206. + sta string'length
  207. tay
  208.  
  209. - lda (251),y
  210. sta string3,y
  211. dey
  212. bpl -
  213. rts
  214.  
  215. ;**** Line Links ****
  216.  
  217. line'links ldy #24
  218. - lda 217,y
  219. ora #128
  220. sta 217,y
  221. dey
  222. bpl -
  223. rts
  224.  
  225. ;**** wait ****
  226. wait lda 53265       
  227. bpl wait   
  228. rts
  229.  
  230. ;**** SCREEN STASH ****
  231.  
  232. screen'stash ldy number
  233. cpy #9 ; ahem!  there are only 9 screens (0-8)
  234. bcc +
  235. rts
  236.  
  237. + sei
  238. ldx #0
  239. lda 1
  240. sta temp
  241. stx 1
  242. lda screens,y
  243. stx 253
  244. sta 254;  dest screen
  245. lda 648
  246. sta 252;  source screen
  247. ldy #0
  248. sty 251
  249.  
  250. ;begin copying
  251.  
  252. - lda (251),y
  253. sta (253),y
  254. iny
  255. bne -
  256. inx
  257. inc 254
  258. inc 252
  259.  
  260. cpx #4
  261. bne -
  262. ldx #0
  263.  
  264. lda #>55296
  265. sta 252
  266.  
  267. - dec 1
  268. lda (251),y
  269. inc 1
  270. sta (253),y
  271. iny
  272. bne -
  273. inc 252
  274. inc 254
  275. inx
  276. cpx #4
  277. bne -
  278.  
  279. lda temp
  280. sta 1
  281. cli
  282. lda 53280
  283. ldy number
  284. sta border,y
  285. lda 53281
  286. sta background,y
  287. rts
  288.  
  289. screen'restore  ldy number
  290. cpy #9 ; ahem!  there are only 9 screens (0-8)
  291. bcc +
  292. rts
  293.  
  294. / lda 53265
  295. bpl -
  296.  
  297. sei
  298. ldx #0
  299. lda 1
  300. sta temp
  301. stx 1
  302. lda screens,y
  303. stx 253
  304. sta 254;  source screen
  305. lda 648
  306. sta 252;  dest screen
  307. ldy #0
  308. sty 251
  309.  
  310. ;begin copying
  311.  
  312. - lda (253),y
  313. sta (251),y
  314. iny
  315. bne -
  316. inx
  317. inc 254
  318. inc 252
  319.  
  320. cpx #4
  321. bne -
  322. ldx #0
  323.  
  324. lda #>55296
  325. sta 252
  326.  
  327. - lda (253),y
  328. dec 1
  329. sta (251),y
  330. inc 1
  331. iny
  332. bne -
  333. inc 252
  334. inc 254
  335. inx
  336. cpx #4
  337. bne -  
  338.  
  339. lda temp
  340. sta 1
  341. cli
  342.  
  343. ldy number
  344. lda border,y
  345. sta 53280
  346. lda background,y
  347. sta 53281
  348. rts
  349.  
  350. ;****** HELP ******
  351.  
  352. helpsc lda #4
  353. sta number
  354. jsr screen'stash
  355.  
  356. lda #0
  357. sta 53280
  358. sta 53281
  359.  
  360. lda #0
  361. sta 212
  362. lda #147
  363. jsr $ffd2
  364.  
  365. lda #>chunk'o'text
  366. sta 252
  367. lda #<chunk'o'text
  368. sta 251
  369. ldy #0
  370.  
  371. - lda (251),y
  372.  
  373. beq finis
  374. cmp #"\"
  375. beq switch'to'white
  376. cmp #"@"
  377. beq switch'to'cyan'reverse
  378.  
  379. bump'help jsr $ffd2
  380. cmp #13
  381. bne +
  382. lda 214
  383. cmp #23
  384. bne +
  385. sty temp
  386. jsr press
  387. lda #0
  388. sta 212
  389. lda #147
  390. jsr $ffd2
  391. ldy temp
  392.  
  393. + iny
  394. bne -
  395. inc 252
  396. bne -
  397.  
  398. switch'to'white lda #1
  399. sta 646
  400. lda #0
  401. sta 199
  402. jmp bump'help
  403.  
  404. switch'to'cyan'reverse lda #3
  405. sta 646
  406. sta 199
  407. jmp bump'help
  408.  
  409. finis lda #0
  410. sta 198
  411.  
  412. jsr press
  413.  
  414. lda #4
  415. sta number
  416. jsr screen'restore
  417. rts
  418.  
  419. ;**** move line ****
  420. ;from line, to line
  421.  
  422. move'line2 ldx #2
  423. stx numbers'to'get
  424. jsr get'number
  425. jsr wait
  426. jsr move
  427. rts
  428.  
  429. move lda number
  430. bpl +
  431. sec
  432. sbc #128
  433. + cmp #25
  434. bcc +
  435. rts
  436. + asl
  437. tay
  438. lda color'mem,y
  439. sta 251
  440. lda screen'mem,y
  441. sta 253
  442. iny
  443. lda color'mem,y
  444. sta 252
  445. lda screen'mem,y
  446. sta 254
  447.  
  448. ldy #39
  449. - lda (253),y
  450. sta string,y
  451. lda (251),y
  452. sta string2,y
  453. dey
  454. bpl -
  455.  
  456. ldx number
  457. bmi +
  458. jsr 59903
  459.  
  460. + lda number+1
  461. asl
  462. tay
  463. lda color'mem,y
  464. sta 251
  465. lda screen'mem,y
  466. sta 253
  467. iny
  468. lda color'mem,y
  469. sta 252
  470. lda screen'mem,y
  471. sta 254
  472.  
  473. ldy #39
  474. - lda string,y
  475. sta (253),y
  476. lda string2,y
  477. sta (251),y
  478. dey
  479. bpl -
  480.  
  481. lda #19    
  482. jmp $ffd2   
  483.  
  484.  
  485. ;**** FILL **** line,to line,col,to col,color
  486.  
  487. fill lda number
  488. cmp #25
  489. bcc +
  490. rts
  491. + asl
  492. tay
  493. lda color'mem,y
  494. sta 251
  495. iny
  496. lda color'mem,y
  497. sta 252
  498.  
  499.  
  500. ldy number+3
  501. lda number+4
  502. - sta (251),y
  503. dey
  504. bmi +
  505. cpy number+2
  506. bcs -
  507.  
  508. + rts
  509.  
  510. ;**** BOX **** lin,tlin,col,to col,s-code,color
  511.  
  512. box lda number
  513. asl
  514. tay
  515. lda color'mem,y
  516. sta 251
  517. lda screen'mem,y
  518. sta 253
  519. iny
  520. lda color'mem,y
  521. sta 252
  522. lda screen'mem,y
  523. sta 254
  524.  
  525. ldy number+3
  526. - lda number+4
  527. sta (253),y
  528. lda number+5
  529. sta (251),y
  530. dey
  531. bmi +
  532. cpy number+2
  533. bcs -
  534. + rts
  535.  
  536. ;********** color swap ******
  537. ;color,to color
  538.  
  539. color ldx #2
  540. stx numbers'to'get
  541. jsr get'number
  542.  
  543. lda #>55296
  544. sta 252
  545. ldx #1
  546. ldy #0
  547. sty 251
  548.  
  549. jsr wait
  550.  
  551. - lda (251),y
  552. and #15
  553. cmp number
  554. beq change'color
  555. iny
  556. bne -
  557. inx
  558. inc 252
  559. cpx #5
  560. bne -
  561. rts
  562.  
  563. change'color lda number+1
  564. sta (251),y
  565. jmp -
  566.  
  567. ;********** char swap ******
  568. ;char,to char,color
  569.  
  570. char ldx #3
  571. stx numbers'to'get
  572. jsr get'number
  573.  
  574. lda #>55296
  575. sta 254
  576. ldx #1
  577. ldy #0
  578. sty 251
  579. sty 253
  580. lda 648
  581. sta 252
  582.  
  583. jsr wait
  584.  
  585. - lda (251),y
  586. cmp number
  587. beq swap
  588. iny
  589. bne -
  590. inx
  591. inc 252
  592. inc 254
  593. cpx #5
  594. bne -
  595. rts
  596.  
  597. swap lda number+1
  598. sta (251),y
  599. lda number+2
  600. bmi +
  601. sta (253),y
  602. + jmp -
  603.  
  604. ;**** MESSAGE ****
  605.  
  606. message'routine lda #4
  607. sta number
  608. jsr screen'stash
  609.  
  610. lda fade'screen
  611. beq naw
  612. lda #0
  613. sta number
  614. sta number+2
  615. lda #24
  616. sta number+1
  617. lda #39
  618. sta number+3
  619. lda fade'color
  620. sta number+4
  621. jsr fill'routine
  622.  
  623. naw ldy #5
  624. - lda box'parms,y
  625. sta number,y
  626. dey
  627. bpl -
  628.  
  629. jsr box'routine
  630.  
  631. lda string'length
  632. lsr
  633. sta string'length+1
  634. lda #20
  635. sec
  636. sbc string'length+1
  637. sta string'length+1
  638. lda starting'line
  639. clc
  640. adc #1
  641. tax
  642. ldy string'length+1
  643. clc
  644.  
  645. jsr plot
  646. lda rvs'text
  647. sta 199
  648. lda box'color
  649. sta 646
  650.  
  651. ldy #0
  652.  
  653. - lda string3,y
  654. jsr $ffd2
  655. iny
  656. cpy string'length
  657. bne -
  658.  
  659. - bit 197
  660. bvs -
  661.  
  662. lda #4
  663. sta number
  664. jsr screen'restore
  665. rts
  666.  
  667. ;**** SET MESSAGE ****
  668. ;sys49152,2,fade?,fade color,rvs text?,box/text col,start line,char,string
  669.  
  670.  
  671. set'message lda number
  672. sta fade'screen
  673. lda number+1
  674. sta fade'color
  675. lda number+2
  676. sta rvs'text
  677. lda number+3
  678. sta box'color
  679. sta box'parms+5
  680. lda number+4
  681. cmp #21
  682. bcc +
  683. lda #20
  684. + sta starting'line
  685. sta box'parms
  686. clc
  687. adc #3
  688. sta box'parms+1
  689. lda number+5
  690. sta box'parms+4
  691. rts
  692.  
  693. plot cpx #25
  694. bcs +
  695. jsr $fff0
  696. + rts
  697.  
  698. ;**** RVS **** lin,tlin,col,to col,color <128
  699.  
  700. rvs lda number
  701. cmp #25
  702. bcc +
  703. rts
  704. + asl
  705. tay
  706. lda color'mem,y
  707. sta 251
  708. lda screen'mem,y
  709. sta 253
  710. iny
  711. lda color'mem,y
  712. sta 252
  713. lda screen'mem,y
  714. sta 254
  715.  
  716. ldy number+3
  717. - lda (253),y
  718. eor #128
  719. sta (253),y
  720. lda number+4
  721. bmi +
  722. sta (251),y
  723. + dey
  724. bmi +
  725. cpy number+2
  726. bcs -
  727. + rts
  728.  
  729. ;directory
  730.  
  731. dir lda string'length
  732. ldy #>string3
  733. ldx #<string3
  734. jsr $ffbd;          setnam
  735. lda #17;            file number
  736. ldx device
  737. ldy #0
  738. jsr $ffba; n        setlfs
  739. jsr $ffc0;           open
  740. ldx #17
  741. jsr $ffc6;         
  742.  
  743. jsr $ffcf;            get byte
  744. jsr $ffcf;             get byte;        skip first two bytes
  745.  
  746. first jsr $ffb7;     read status
  747. and #64
  748. bne dir'out
  749.  
  750. jsr $ffcf;             get byte
  751. jsr $ffcf;             get byte;         skip two bytes
  752.  
  753. second jsr $ffb7
  754. and #64;              eof?
  755. bne dir'out
  756. jsr $ffcf;             get byte
  757. tax
  758. jsr $ffcf;             get byte
  759. jsr $bdcd
  760. lda " "
  761. jsr $ffd2
  762.  
  763. jsr $ffb7
  764. and #64;               eof?
  765. bne dir'out
  766.  
  767. third jsr $ffcf;             get byte
  768. bne +
  769.  
  770. lda #13
  771. jsr $ffd2
  772. jmp first
  773.  
  774. + jsr $ffd2
  775.  
  776. - lda 197
  777. cmp #64
  778. bne -
  779. lda 653
  780. bne -
  781.  
  782. jsr $ffb7
  783. and #64
  784. bne dir'out
  785.  
  786. jmp third
  787.  
  788. dir'out lda #17
  789. jsr $ffc3;            close17
  790. jsr $ffcc ;clear chan
  791.  
  792. rts
  793.  
  794. file'read lda string'length
  795. ldy #>string3
  796. ldx #<s